Create some maps
LOCATION INFO:
# Get longitude and latitude information for use with MAPs:
latmax <- max( finaldf$lat, na.rm = TRUE )
latmin <- min( finaldf$lat, na.rm = TRUE )
lonmax <- max( finaldf$long, na.rm = TRUE )
lonmin <- min( finaldf$long, na.rm = TRUE )
latvals <- c( latmin, latmax )
lonvals <- c( lonmin, lonmax )
MAP 1:
newmap <- getMap( resolution="low" )
plot( newmap, xlim = lonvals, ylim = latvals, asp=1 )
points( finaldf$long, finaldf$lat, col="red", cex=.6 )

MAP 2:
berkMap = map = get_map(location = c( lon = mean(lonvals), lat = mean(latvals) ), zoom = 13)
## Warning in download.file(url, destfile = tmp, quiet = !messaging, mode =
## "wb"): downloaded length 627710 != reported length 627710
## Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=37.865887,-122.276384&zoom=13&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
ggmap(berkMap) +
geom_point(aes(x = long, y = lat, colour = Incident.Type.Class), data = finaldf, alpha = 0.7) +
scale_colour_discrete( "Incident Type", labels = c("Pedestrian Stop", "Bicycle Stop", "Suspicious Vehicle Stop", "Traffic Stop" ) ) +
theme (
#legend.position = c(0.05, 0.05), # put the legend INSIDE the plot area
#legend.justification = c(0, 0),
#legend.background = element_rect(colour = F, fill = "white"),
#legend.key = element_rect (fill = F, colour = F),
panel.grid.major = element_blank (), # remove major grid
panel.grid.minor = element_blank (), # remove minor grid
axis.text = element_blank (),
axis.title = element_blank (),
axis.ticks = element_blank ()
) +
ggtitle("BPD Stops 2015-2016")

MAP 3:
ggmap(berkMap) +
geom_point(aes(x = long, y = lat, colour = factor(Gender)), data = mergedf, alpha = 0.7) +
scale_colour_discrete( "Gender", labels = c("Female", "Male") ) +
theme (
panel.grid.major = element_blank (), # remove major grid
panel.grid.minor = element_blank (), # remove minor grid
axis.text = element_blank (),
axis.title = element_blank (),
axis.ticks = element_blank ()
) +
ggtitle("BPD Stops 2015-2016")

MAP 4:
ggmap(berkMap) +
geom_point(aes(x = long, y = lat, colour = factor(Race)), data = mergedf, alpha = 0.7, size = 3) +
scale_colour_discrete( "Race", labels = c("Asian", "Black", "Hispanic", "Other", "White") ) +
theme (
panel.grid.major = element_blank (), # remove major grid
panel.grid.minor = element_blank (), # remove minor grid
axis.text = element_blank (),
axis.title = element_blank (),
axis.ticks = element_blank ()
) + ggtitle("BPD Stops 2015-2016")
